<% def user_logged_in = application.getAttribute("org.codehaus.groovy.grails.APPLICATION_CONTEXT").getBean("springSecurityService").currentUser %>
<% def authenticationManagerService = application.getAttribute("org.codehaus.groovy.grails.APPLICATION_CONTEXT").getBean("authenticationManagerService") %>
<html lang="th">
  <head>
    <meta charset="utf-8"/>
        <title><g:layoutTitle default="Grails"/></title>
	<link rel="stylesheet" href="${resource(dir: 'css', file: 'layout.css')}" type="text/css" media="screen" />
	<script src="${resource(dir: 'js', file: 'jquery-1.7.1.min.js')}" type="text/javascript"></script>
	<script src="${resource(dir: 'js', file: 'hideshow.js')}" type="text/javascript"></script>
	<script src="${resource(dir: 'js', file: 'jquery.tablesorter.min.js')}" type="text/javascript"></script>
	<script src="${resource(dir: 'js', file: 'jquery.equalHeight.js')}" type="text/javascript"></script>
	<script type="text/javascript">
	$(document).ready(function() 
    	{ 
      	  $(".tablesorter").tablesorter(); 
   	 } 
	);
	$(document).ready(function() {
	//When page loads...
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

        });
    </script>
    <script type="text/javascript">
       $(function(){
        $('.column').equalHeight();
       });
    </script>
    <g:layoutHead/>
    <r:layoutResources />
  </head>
  <body>
    <header id="header">
		<hgroup>
			<h1 class="site_title">Pumbaa</h1>
		</hgroup>
	</header> <!-- end of header bar -->
	
	<section id="secondary_bar">
		<div class="user">
			<!-- For Login And Logout Form -->
			
                        <sec:ifLoggedIn>
                          <p><g:link controller="user" action="edit" id="${user_logged_in.id}">Welcome, <sec:username/></g:link> <g:link controller="user" action="listOfRequest">(${authenticationManagerService.getNumberOfRequestUser()} User Request)</g:link></p>
                          <a class="logout_user" href="/Pumbaa/logout" title="Logout">Logout</a>
                        </sec:ifLoggedIn>
                        <sec:ifNotLoggedIn>
                          <p><g:link controller='login' action='auth'>Login</g:link>&nbsp;&nbsp;&nbsp;<g:link controller='user' action='create'>Sign Up</g:link></p>
                        </sec:ifNotLoggedIn>
			
		</div>
                <pumbaa:navigation navInstance="${navigation}"/>
	</section><!-- end of secondary bar -->

        <aside id="sidebar" class="column">
		<form class="quick_search">
			<input type="text" value="Quick Search" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;">
		</form>
		<hr/>
		<h3>Content</h3>
		<ul class="toggle">
                      <g:if test="${(user_logged_in != null) && (user_logged_in.role.level <= 1)}">
                        <li class="icn_new_article"><g:link controller="category" action="create">New Category</g:link></li>
                      </g:if>
                        <li class="icn_categories"><g:link controller="category">Categories</g:link></li>
			<li class="icn_tags"><g:link controller="event">Calendar</g:link></li>
		</ul>
                <g:if test="${user_logged_in != null}">
                  <h3>Users</h3>
                  <ul class="toggle">
                        <li class="icn_profile"><g:link controller="user" id="${user_logged_in.id}" action="edit">Your Profile</g:link></li>
                        <li class="icn_view_users"><g:link controller="user" action="subscription">Subscriptions</g:link></li>
                  </ul>
                </g:if>
                  <g:if test="${user_logged_in?.role?.level == 0}">
                    <h3>Admin</h3>
                    <ul class="toggle">
                      <li class="icn_add_user"><g:link controller="user">User Manager</g:link></li>
                        <li class="icn_settings"><g:link controller="role">Role Manager</g:link></li>
                    </ul>
                  </g:if>
                <footer>
			<hr />
			<p><strong>Powered by CoE 20.</strong></p>
			<p>Theme by <a href="http://www.medialoot.com">MediaLoot</a></p>
		</footer>
	</aside><!-- end of sidebar -->
        <g:layoutBody/>
    <r:layoutResources />
  </body>
</html>
